package com.socialbank.web.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.socialbank.web.bean.Good;
import com.socialbank.web.bean.GoodsRecommend;

public interface RecommendGoodsMapper {

	@Insert("INSERT INTO bns_goods_recommend (id, goods_id, dept_id, create_date) VALUES (#{id}, #{goodsId}, #{deptId}, NOW())")
	public int addRecommendGoods(GoodsRecommend goodsRecommend);

	
	
	@Update("UPDATE bns_goods SET recommend = #{recommend} WHERE id = #{goodsId}")
	public int modifyGoodsRecommend(GoodsRecommend goodsRecommend);


	@Select("SELECT t1.id, t1.NAME, t1.price, t1.bidding, t1.business_id, t1.img_goods, t1.category_id, t1.specification, t1.recommend, t1.params, t1.sku, t1.synopsis, t1.create_date, t1.`status` FROM bns_goods t1 RIGHT JOIN bns_goods_recommend t0 ON t0.goods_id = t1.id where t1.recommend = 1")
	public List<Good> findRecommendGoods();
	
	
	
	@Select("SELECT id, goods_id as goodsId, dept_id as deptId, create_date as createDate FROM bns_goods_recommend where goods_id = #{goodsId}")
	public GoodsRecommend findRecommendOfGoodsId(GoodsRecommend goodsRecommend);
	
	
}
